package fu.capstone.hanoicityguide.presentation.fragment.transportation;

import fu.capstone.hanoicityguide.R;
import fu.capstone.hanoicityguide.business.bo.bus.BusBO;
import fu.capstone.hanoicityguide.business.bo.bus.BusBOImp;
import fu.capstone.hanoicityguide.business.model.Bus;
import android.app.Fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class DetailBusFragment extends Fragment {

	private BusBO busBO;
	private int busID;
	private TextView firstLeg;
	private TextView secondLeg;
	private TextView price;

	public DetailBusFragment() {

	}

	public DetailBusFragment(int busID) {
		this.busID = busID;
	}

	public int getBusID() {
		return this.busID;
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub

		View browseBusFragment = inflater.inflate(R.layout.fragment_detail_bus,
				container, false);
		try {
			busBO = new BusBOImp(container.getContext());
			Bus bus = busBO.browseBus(busID);

			firstLeg = (TextView) browseBusFragment
					.findViewById(R.id.txtFirstLeg);
			firstLeg.setText(bus.getFirstLeg());

			secondLeg = (TextView) browseBusFragment
					.findViewById(R.id.txtSecondLeg);
			secondLeg.setText(bus.getSecondLeg());

			price = (TextView) browseBusFragment.findViewById(R.id.txtPrice);
			price.setText(bus.getPrice() + " VND");
		} catch (Exception e) {
			Log.e("DetailBusFragment : ", e.toString());
		}

		return browseBusFragment;
	}

}
